package com.qdlc.p2p.biz.processor.task;

import java.util.Map;

import com.qdlc.p2p.biz.processor.event.NoticeTemplateValueEvent;
import com.qdlc.p2p.common.core.queue.TaskProcessorException;
import com.qdlc.p2p.common.core.queue.ValueEvent;
import com.qdlc.p2p.dal.dto.User;

public abstract class AbstractNoticeTemplateTaskProcessor extends AbstractTaskProcessor {

	@Override
	public boolean supports(ValueEvent event) {
		return event instanceof NoticeTemplateValueEvent;
	}

	@Override
	protected void process0(ValueEvent event) throws TaskProcessorException {
		//获取模版类型和模版数据
		NoticeTemplateValueEvent templateEvent = (NoticeTemplateValueEvent)event;
		String noticeTypeNid = templateEvent.getNoticeTypeNid();
		Map<String, Object> sendData = templateEvent.getSendData();
		User user = templateEvent.getUser();
        if(user == null){
        	throw new TaskProcessorException(templateEvent, "User can't null");
        }
        sendData.put("user", user);
        processInternal(noticeTypeNid, sendData, user);
	}

	protected abstract void processInternal(String noticeTypeNid, Map<String, Object> sendData, User user) throws TaskProcessorException;
}
